package com.axin.web.controller;

import com.axin.blog.api.RemoteCategoryService;
import com.axin.blog.api.RemoteCommentService;
import com.axin.blog.api.domain.BlogComment;
import com.axin.blog.api.domain.WebUser;
import com.axin.blog.api.vo.BlogCommentVo;
import com.axin.common.core.domain.web.AjaxResult;
import com.axin.common.core.domain.web.TableDataInfo;
import com.axin.web.annotation.CurrentUser;
import com.axin.web.annotation.IgnoreAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论 web接口
 *
 * @Author axin
 * @Date 2021/11/2 21:35
 **/
@RestController
@RequestMapping("/comment")
public class ApiCommentController {


    @Autowired
    private RemoteCommentService remoteCommentService;

    /**
     * 查询评论别表
     * @param pageNum
     * @param pageSize
     * @param blogId
     * @return
     */
    @IgnoreAuth
    @GetMapping("/getCommentList")
    public TableDataInfo<BlogCommentVo> getCommentList(@RequestParam("pageNum") Integer pageNum,
                                                       @RequestParam("pageSize") Integer pageSize,
                                                       @RequestParam("blogId") Long blogId) {
        return remoteCommentService.getCommentList(pageNum, pageSize, blogId);
    }


    @PostMapping("/comment")
    public AjaxResult getCommentList(@CurrentUser WebUser loginUser,
                                     @RequestBody BlogComment comment) {
        comment.setUserId(loginUser.getUserId());
        return remoteCommentService.comment(comment);
    }

}
